<!-- @format -->

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<style>
			div {
				width: 200px;
				height: 200px;
				background-color: pink;
			}

			.nav {
				color: red;
			}

			.box {
				width: 300px;
				height: 300px;
				background-color: skyblue;
				margin: 100px auto;
				padding: 10px;
				border: 1px solid #000;
			}
		</style>
	</head>

	<body>
		<div class="nav">123</div>
		<script>
			// 1. 获取元素
			const divEle = document.querySelector(".nav");
			// 2.添加类名  class 是个关键字 我们用 className
			divEle.className = "nav box";
		</script>
	</body>
</html>
